package Model;

import zOthers.Log;

public class ModelFrameMain extends AbstractModel {
	private static final String TAG = "ModelFrameMain";

	public static final Integer PANEL_ID_MENU = 0;
	public static final Integer PANEL_ID_GAME = 1;
	public static final Integer PIXEL_FRAME_WIDTH = 800;
	public static final Integer PIXEL_FRAME_HEIHGT = 700;

	private Integer panelID;
	private ModelPanelStartMenu mPanelLogin;
	//private ModelPanelGame mPanelGame;

	/*
	 * Constructor
	 */
	public ModelFrameMain() {
		// Do nothing
	}

	public void modelInitialization() {
		setPanelID(0);
	}

	/*
	 * Mutators
	 */
	public void setPanelID(Integer pId) {
		Log.info(TAG, "setPanelID() called PanelID: "+pId);

		Integer oldPanelID;
		if(panelID == null)
			oldPanelID = -1;
		else
			oldPanelID = panelID;
		panelID = pId;

		// Doesn't do anything for now
		panelSwitchHandler(oldPanelID, panelID);

		/*
		 *  Fire the new property
		 *  ViewFrameMain.modelPropertyChange catches it
		 */
		firePropertyChange("panelID", oldPanelID, panelID);
	}

	public void setModelPanelLogin(ModelPanelStartMenu mPL){//(ModelPanelMenu mPM) {
		mPanelLogin = mPL;
	}

	public void setModelPanelGame(){//(ModelPanelGame mPG) {
		//mPanelGame = mPG;
	}

	/*
	 * Accessors
	 */
	public Integer getPanelID() {
		return panelID;
	}

	/*
	 * This method is called whenever a switch between different panels happens.
	 * (Still need to be modified)
	 */
	private void panelSwitchHandler(Integer previousPanelID, Integer nextPanelID) {
		if(previousPanelID == PANEL_ID_MENU && nextPanelID == PANEL_ID_GAME) {
			//mPanelGame.setMap(WorldWar.mapLoader.getMapsList().get(mPanelMenu.getSelectedMapIndex()));
		}
	}
}
